package com.hmall.gateway.filter;

import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;


//@Component
public class PrintAnyGatewayFilterFactory extends AbstractGatewayFilterFactory<Object> {
    @Override
     public GatewayFilter apply(Object config) {
        return (exchange, chain) -> {
            System.out.println("过滤器开始执行了--->");
            ServerHttpRequest request = exchange.getRequest();
            ServerHttpResponse response = exchange.getResponse();
            System.out.println(request);
            System.out.println(response);
            //交给下一个过滤器去执行
            return chain.filter(exchange);
        };
    }
}
